﻿Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Seuss.EnterpriseLibrary.DataAccess
Imports Seuss.EnterpriseLibrary.BusinessLogic
Imports System.Web
Imports System.Data


Partial Class Consulta_DO_ListaCursAsig
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Expires = -1
        Response.AddHeader("Pragma", "no-cache")
        Response.AddHeader("cache-control", "private")
        Response.CacheControl = "no-cache"
        Dim DivPrincipal As New StringBuilder
        If Not Page.IsPostBack Then
            Dim ldrcurprepgrado As New List(Of IDataReader)
            Dim ldrcurpostpgrado As New List(Of IDataReader)
            Dim ldrcurextra As New List(Of IDataReader)
            Dim TB As DataTable
            Dim TB2 As DataTable
            Dim TB3 As DataTable
            Using ObjPool As New PoolDbCommand()
                Dim ObjUsuario As New DAL_Kiosco(ObjPool.Database)
                'PREGRADO
                ObjPool.AddDbCommand(ObjUsuario.Get_CursosAsignados_Pregrado_By_cPerCodigo(IdentityUser.UserCode), PoolDbCommand.PoolDbCommandResultType.Query)
                ObjPool.Pooling(Nothing, ldrcurprepgrado, True)
                TB = Helper.LoadDataTable(ldrcurprepgrado(0))
                'EXTRA
                ObjPool.AddDbCommand(ObjUsuario.Get_CursosAsignados_ExtraCurriculares_By_cPerCodigo(IdentityUser.UserCode), PoolDbCommand.PoolDbCommandResultType.Query)
                ObjPool.Pooling(Nothing, ldrcurextra, True)
                TB2 = Helper.LoadDataTable(ldrcurextra(0))
                'POSTGRADO
                ObjPool.AddDbCommand(ObjUsuario.Get_CursosAsignados_Postgrado_By_cPerCodigo(IdentityUser.UserCode), PoolDbCommand.PoolDbCommandResultType.Query)
                ObjPool.Pooling(Nothing, ldrcurpostpgrado, True)
                TB3 = Helper.LoadDataTable(ldrcurpostpgrado(0))
            End Using
            'PREGRADO
            Dim asignatura As String = ""
            If ldrcurprepgrado.Count <> 0 Then
                If TB.Rows.Count <> 0 Then
                    DivPrincipal.Append("<table width='100%' style='text-align:left;'>")
                    For Each fila In TB.Rows
                        If asignatura <> fila.Item("cAsiDescripcion").ToString And fila.Item("orden").ToString = 0 Then
                            DivPrincipal.Append("<tr><td style='font-size:12px; padding-left:5%;'><img src='../Imagenes/Ok2.gif' /> " + fila.Item("cAsiDescripcion").ToString + "</td></tr>")
                            asignatura = fila.Item("cAsiDescripcion").ToString
                            DivPrincipal.Append("<tr><td class=""listview"" style='padding-left:10px; text-align:center;'><ul>")
                            For Each fila2 In TB.Rows
                                If fila2.Item("orden").ToString = 0 Then
                                    If asignatura = fila2.Item("cAsiDescripcion").ToString Then
                                        DivPrincipal.Append("<li><a style='font-size:14px; Color:#255B7F;' href=DO_CursoAsignado.aspx?nGruCodigo=" & fila2.Item("nGruCodigo").ToString & "&nCurGruCodigo=" + fila2.Item("nCurGruCodigo").ToString + ">" + fila2.Item("cGruNombre").ToString + " / " + fila2.Item("cAsiDescripcion").ToString + "</a></li>")
                                    End If
                                End If
                            Next
                            DivPrincipal.Append("</ul></td></tr>")
                        End If

                    Next
                    DivPrincipal.Append("</table>")
                End If
            End If
            'EXTRA
            asignatura = ""
            If ldrcurextra.Count <> 0 Then
                If TB2.Rows.Count <> 0 Then
                    DivPrincipal.Append("<table width='100%' style='text-align:left;'>")
                    For Each fila In TB2.Rows
                        If asignatura <> fila.Item("cAsiDescripcion").ToString Then
                            DivPrincipal.Append("<tr><td style='font-size:12px; padding-left:5%;'><img src='../Imagenes/Ok2.gif' /> " + fila.Item("cAsiDescripcion").ToString + "</td></tr>")
                            asignatura = fila.Item("cAsiDescripcion").ToString
                            DivPrincipal.Append("<tr><td class=""listview"" style='padding-left:10px; text-align:center;'><ul>")
                            For Each fila2 In TB2.Rows
                                If asignatura = fila2.Item("cAsiDescripcion").ToString Then
                                    DivPrincipal.Append("<li><a style='font-size:14px; Color:#255B7F;' href=DO_CursoAsignado.aspx?nGruCodigo=" & fila2.Item("nGruCodigo").ToString & "&nCurGruCodigo=" + fila2.Item("nCurGruCodigo").ToString + ">" + fila2.Item("cAsiDescripcion").ToString + " / Sec: " + fila2.Item("seccion").ToString + "</a></li>")
                                End If
                            Next
                            DivPrincipal.Append("</ul></td></tr>")
                        End If

                    Next
                    DivPrincipal.Append("</table>")
                End If
            End If
            'POSTGRADO
            asignatura = ""
            If ldrcurpostpgrado.Count <> 0 Then
                If TB3.Rows.Count <> 0 Then
                    DivPrincipal.Append("<table width='100%' style='text-align:left;'>")
                    For Each fila In TB3.Rows
                        If asignatura <> fila.Item("cUniOrgAbrev").ToString Then
                            DivPrincipal.Append("<tr><td style='font-size:12px; padding-left:5%;'><img src='../Imagenes/Ok2.gif' /> " + fila.Item("cUniOrgAbrev").ToString + "</td></tr>")
                            asignatura = fila.Item("cUniOrgAbrev").ToString
                            DivPrincipal.Append("<tr><td class=""listview"" style='padding-left:10px; text-align:center;'><ul>")
                            For Each fila2 In TB3.Rows
                                If asignatura = fila2.Item("cUniOrgAbrev").ToString Then
                                    DivPrincipal.Append("<li><a style='font-size:14px; Color:#255B7F;' href=DO_CursoAsignado.aspx?nGruCodigo=" & fila2.Item("nGruCodigo").ToString & "&nCurGruCodigo=" + fila2.Item("nCurGruCodigo").ToString + ">" + fila2.Item("cAsiDescripcion").ToString + "</a></li>")
                                End If
                            Next
                            DivPrincipal.Append("</ul></td></tr>")
                        End If

                    Next
                    DivPrincipal.Append("</table>")
                End If
            End If

        End If
        lblcontenido.Text = DivPrincipal.ToString
        Using Seguridad As New BLL_Administracion
            Seguridad.Set_Transaccion_Insert(Nothing, 100401, IdentityUser.UserCode, My.Request.UserHostAddress.ToString, CrearXMLTransaccion("Consulta Pagina Movil", "/Pagina|" + My.Request.Url.Segments(My.Request.Url.Segments.Length - 1).ToString))
        End Using
    End Sub

End Class